<template>
    <div class="arraryFromString">
      <div>
        <span> 数组：{{ array }} </span>
        <span> 数组：{{ string }} </span>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        array: ["关羽", "张飞", "赵云", "马超", "黄忠"],
        string: "老子，原始，通天",
      };
    },
    methods: {
      arrayToString() {
          this.array = this.array?.join(",");
      },
      stringToArray(){
          this.string = this.string.split(',')
      }
    },
    created() {},
    mounted() {
      this.arrayToString();
      this.stringToArray()
    },
  };
  </script>
  <style scoped></style>
  